package com.example.qxfw.common.util;

public class NumberFormat {
    public static String formatNumber(String str){
        if(str.indexOf(".")>0){
            //删除尾数为0的字符
            str=str.replaceAll("0+?$","");
            //删除尾数为小数点的字符
            str=str.replaceAll("[.]$","");
        }
        return str;
    }

    public static String formatNumber(float f){
        String str = Float.toString(f);
        if(str.indexOf(".")>0){
            //删除尾数为0的字符
            str=str.replaceAll("0+?$","");
            //删除尾数为小数点的字符
            str=str.replaceAll("[.]$","");
        }
        return str;
    }
}
